using System;
using System.Collections;
using System.Collections.Generic;
using GameFramework.common;
using GameFramework.events;
using GameFramework.timer;
using GameFramework.UI;
using UnityEngine;
using UnityEngine.UIElements;
using Event = UnityEngine.Event;

namespace Game.ui
{
    [View(SceneViewManagerName = SceneViewManagerNames.SceneLoading)]
    [Presenter(type = typeof(SceneLoadingPresenter))]
    public class SceneLoadingView : BaseView
    {
        [UIBind(ClassName = "loadingbar-front")]
        private VisualElement  processBar;

        [UIBind(ClassName = "loadingbar-bg")] 
        private VisualElement loadingbarBg;
        [UIBind(ClassName = "processSqure")] 
        private VisualElement processSqure;
        public override void beforeShow()
        {
            Debug.Log("注册事件！");
            MVPEventManager.Instance.SceneLoadingView_ProcessChange += processChange;
        }

        private void processChange(float nowProcess)
        {
            Debug.Log("加载界面进度变化："+nowProcess);
            loadingbarBg.style.width = new Length(nowProcess, LengthUnit.Percent);
        }

        public override void afterShow()
        {
            base.afterShow();
            processSqure.AddToClassList("rotateStart");
        }

        public override void beforeHide()
        {
            processSqure.RemoveFromClassList("rotateStart");
        }


    }
}


